

	function checknumber(String){
		var letters = "0123456789.";
		var c;
		for( var i = 0; i < String.length; i ++ ){
		 c = String.charAt( i );
		 if (letters.indexOf( c ) ==-1)
			return true;
		}
		return false;
	}
	
	function checkPageValid(){
		var obj = document.getElementsByTagName("INPUT");
		var itemValue;
		if(obj){
			for(var i=0;i<obj.length;i++){
				if(obj[i].checkItem)
					itemValue = obj[i].checkItem;
				else itemValue="";
				
				if(obj[i].requiredValue=="true"){
					if(obj[i].value==""){
						alert(itemValue+"必须输入，请确认！");
						//obj[i].focus();
						return false;
					}
				}
				if(obj[i].value=="")
					continue;
				if(obj[i].checkType){
					if(obj[i].checkType.indexOf("number")!=-1){
						if(!validate(obj[i].value)){
							alert(itemValue+"必须输入数字，请确认！");
							//obj[i].focus();
							return false;
						}
					}
					if(obj[i].checkType.indexOf("data")!=-1){
						if(!IsValidDate(obj[i].value)){
							alert(itemValue+"的时间格式不对，格式为：YYYY-MM-DD，请确认！");
							//obj[i].focus();
							return false;
						}
					}	
					
					if(obj[i].checkType.indexOf("charnum")!=-1){
						if(!validateCharNum(obj[i].value)){
							alert(itemValue+"的格式不对，格式应该为由字母和数字组成，请确认！");
							//obj[i].focus();
							return false;
						}
					}	
					
					if(obj[i].checkType.indexOf("phone")!=-1){
						if(!validateCharPhone(obj[i].value)){
							alert(itemValue+"的格式不对，格式应该为11位数字，请确认！");
							//obj[i].focus();
							return false;
						}
					}
					
					if(obj[i].checkType.indexOf("telephone")!=-1){
						if(!validateCharTelPhone(obj[i].value)){
							alert(itemValue+"的格式不对，格式应该为dddd-dddddddd，请确认！");
							//obj[i].focus();
							return false;
						}
					}	
					
					if(obj[i].checkType.indexOf("email")!=-1){
						if(!emailCheck(obj[i].value)){
							alert(itemValue+"的格式不对，请确认！");
							//obj[i].focus();
							return false;
						}
					}	
				}
				
				if(obj[i].checkLength){
					var num = parseInt(obj[i].checkLength);
					if(num!=NaN){
						if(len(obj[i].value)>num){
							alert(itemValue+"不能长度大于："+Math.floor(num/2)+"请确认！");
							obj[i].focus();
							return false;
						}
					}
				}
			}
		}
		return true;
	}
	
	//说明格式满足YYYY-MM-DD  
	function IsValidDate(DateStr){   
    	var sDate=DateStr.replace(/(^\s+|\s+$)/g,''); //去两边空格;    
    	if(sDate=='') return true;   
    	var s = sDate.replace(/\d{4}-\d{2}-\d{2}/g,''); 
    	
    	if (s==''){    
        	var t=new Date(sDate.replace(/-/g,'/'));    
        	var ar = sDate.split('-');    
        	if(ar[0] != t.getYear() || ar[1] != t.getMonth()+1 || ar[2] != t.getDate()){    
            	return false;    
        	}    
    	}else{    
        	return false;    
    	}    
    	return true;    
	}    
	
	//说明格式满足YYYY-MM 
	function IsValidYearMouth(DateStr){   
    	var sDate=DateStr.replace(/(^\s+|\s+$)/g,''); //去两边空格;
    	if(sDate=='') return true;   
    	var s = sDate.replace(/\d{4}-\d{2}/g,''); 
    	if (s==''){    
    		sDate = sDate + "-01";
        	var t=new Date(sDate.replace(/-/g,'/')); 
        	var ar = sDate.split('-');    
        	if(ar[0] != t.getYear() || ar[1] != t.getMonth()+1){    
            	return false;    
        	}    
    	}else{    
        	return false;    
    	}    
    	return true;    
	}    
	
	function validate(sDouble){
		var re = /^\d+(?=\.{0,1}\d+$|$)/
		return re.test(sDouble)
	}
	
	function validateCharNum(sDouble){
		var re = /^(\d|[a-zA-Z])*$/
		return re.test(sDouble)
	}
	
	//11位数字
	function validateCharPhone(sDouble){
		var re = /^\d{11}$/g
		return re.test(sDouble)
	}
	
	//dddd-ddddddd
	function validateCharTelPhone(sDouble){
		var re = /^0\d{2,4}-?\d{7,8}$/
		return re.test(sDouble)
	}
	
	function len(s) { 
		var l = 0; 
		var a = s.split(""); 
		for (var i=0;i<a.length;i++) { 
			if (a[i].charCodeAt(0)<299) { 
				l++; 
			} else { 
			l+=2; 	
			} 
		} 
		return l; 
	}
	
	function emailCheck (emailStr) {   
		if(emailStr=="") return true;
    	var emailPat = /^(.+)@(.+)$/;   
   	 	var matchArray = emailStr.match(emailPat);   
    	if (matchArray == null) {  
        	return false;   
    	}else{   
        	return true;   
    	}   
	}  
	